/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       artifact_icon.cpp

	$Header: /game/artifact_icon.h $

	$NoKeywords: $

 ************************************************************************/

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "artifact_icon.h"

#include "artifact_type.h"
#include "artifact_properties.h"
#include "bitmap_layer_cache_window.h"
#include "format_string.h"
#include "simple_dialog.h"

// -------------------------------------------------------------------
// window to display a artifact icon
// -------------------------------------------------------------------

t_artifact_icon::t_artifact_icon( t_artifact const& artifact, t_screen_point const& point, 
								  t_window* parent)
            : t_window( t_screen_rect( point.x, point.y, point.x + 44, point.y + 44),
			            k_some_transparency, parent )
{
	create_image();
	set_artifact( artifact );
}

// -------------------------------------------------------------------
// window to display a artifact icon
// -------------------------------------------------------------------

t_artifact_icon::t_artifact_icon( t_screen_point const& point, t_window* parent)
               : t_window( t_screen_rect( point.x, point.y, point.x + 44, point.y + 44),
			               k_some_transparency, parent )
{
	create_image();
	set_artifact( t_artifact() );
}

// -------------------------------------------------------------------
// window to display a artifact icon
// -------------------------------------------------------------------
void t_artifact_icon::create_image()
{
	m_image = new t_bitmap_layer_cache_window( t_bitmap_layer_ptr(), t_screen_point(0,0),
		                                       this );
}

// -------------------------------------------------------------------
// window to display a artifact icon
// -------------------------------------------------------------------
void t_artifact_icon::set_artifact( t_artifact const& artifact )
{
	m_artifact = artifact;

	if (artifact.get_icon() == k_artifact_none)
	{
		m_image->set_bitmap( t_bitmap_layer_ptr(), true );
		m_image->set_help_balloon_text( "" );
		m_image->set_right_click_text( "" );
		set_help_balloon_text( "" );
		set_right_click_text( "" );
		return;
	}

	t_bitmap_layer_ptr icon;
	
	icon = get_icon( m_artifact.get_icon() );
	m_image->set_bitmap( icon, true );
	m_image->set_help_balloon_text( m_artifact.get_name() );
	std::string right_click_text;
    right_click_text = format_string("%s: %s", m_artifact.get_name().c_str(), m_artifact.get_help_text().c_str());
	m_image->set_right_click_text( right_click_text );
	set_help_balloon_text( m_artifact.get_name() );
	set_right_click_text( m_artifact.get_help_text() );
}

